Imports System
Imports System.Web

Public Class AnchorButton
    Inherits jObjectiveControl

    Private m_sText As String
    Private m_sOnClientClick As String

    Private m_ctlLabel As New WebControls.Label

    Public Property Text() As String
        Get
            Return m_sText
        End Get
        Set(ByVal value As String)
            m_sText = value
        End Set
    End Property

    Public Property TextCssClass() As String
        Get
            Return m_ctlLabel.CssClass
        End Get
        Set(ByVal value As String)
            m_ctlLabel.CssClass = value
        End Set
    End Property

    Public Property OnClientClick() As String
        Get
            Return m_sOnClientClick
        End Get
        Set(ByVal value As String)
            m_sOnClientClick = value
        End Set
    End Property

    Public Sub New()
        MyBase.New(HtmlTextWriterTag.A)

        With m_ctlLabel
            .ID = Common.GetUniqueID(Context)
        End With
    End Sub

    Protected Overrides Sub CreateChildControls()
        MyBase.CreateChildControls()

        With Controls
            .Add(m_ctlLabel)
        End With

        ChildControlsCreated = True
    End Sub

    Private Sub AnchorButton_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
        m_ctlLabel.Text = m_sText

        If Not String.IsNullOrEmpty(m_sOnClientClick) Then
            Attributes("onclick") = m_sOnClientClick
        End If
    End Sub
End Class
